using System.Collections.Generic;
using System.IO;
using System.Linq;
using TLDRML.Tokens;

namespace TLDRML.Nodes
{
    public class DocNode : ElementNode
    {
        public DocNode()
        {
        }

        public DocNode(params Node[] childNodes) : base(childNodes)
        {
        }

        public override IEnumerable<Token> Parse(IEnumerable<Token> tokens)
        {
            while (tokens.Any())
                tokens = Parse<ElementNode>(tokens, AddChild);

            return null;
        }

        public static DocNode LoadText(string text)
        {
            var lexer = new Lexer(new StringReader(text));
            var doc = new DocNode();
            doc.Parse(new CachedEnumerable<Token>(lexer.Tokenize()));
            return doc;
        }
    }
}